from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class knowledge_base_directory_fake :
    def __init__ ( self ) :
        self . _create_knowledge_base = [ ]
        self . _rename_knowledge_base = [ ]
        self . _copy_knowledge_base = [ ]
        self . _list_knowledge_bases = None
        self . _read_file_reply = None
        self . _list_files_reply = None
        self . _current_time_reply = None
        self . _list_knowledge_bases_request = False
        self . _knowledge_base_creation_time_request = None
        self . _knowledge_base_modification_time_request = None
        self . _knowledge_base_size_request = None
    def read_file_reply ( self , name , contents ) :
        self . _read_file_reply = [ name , contents ]
    def list_files_reply ( self , files ) :
        self . _list_files_reply = files
    def current_time_reply ( self , time ) :
        self . _current_time_reply = time
    def create_knowledge_base ( self , name ) :
        self . _create_knowledge_base += [ [ name ] ]
    def rename_knowledge_base ( self , name , new_name ) :
        self . _rename_knowledge_base += [ [ name , new_name ] ]
    def copy_knowledge_base ( self , name , new_name ) :
        self . _copy_knowledge_base += [ [ name , new_name ] ]
    def list_knowledge_bases_request ( self ) :
        self . _list_knowledge_bases_request = True
    def knowledge_base_creation_time_request ( self , name ) :
        self . _knowledge_base_creation_time_request = name
    def knowledge_base_modification_time_request ( self , name ) :
        self . _knowledge_base_modification_time_request = name
    def knowledge_base_size_request ( self , name ) :
        self . _knowledge_base_size_request = name

class mediator_knowledge_base_directory_tests : 
    'mediator_knowledge_base_directory'
    def __init__ ( self , test ) :
        self . _test = test
        self . _knowledge_base_directory = knowledge_base_directory_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'knowledge_base_directory' 
            , self . _knowledge_base_directory 
            , None
            ) )
    def test_read_file_reply ( self ) :
        self . _mediator . read_file_reply ( 'my name' , 'my contents' )
        self . _test . assume_equal ( self . _knowledge_base_directory . _read_file_reply , [ 'my name' , 'my contents' ] )
    def test_list_files_reply ( self ) :
        self . _mediator . list_files_reply ( 'my files' )
        self . _test . assume_equal ( self . _knowledge_base_directory . _list_files_reply , 'my files' )
    def test_current_time_reply ( self ) :
        self . _mediator . current_time_reply ( 'my time' )
        self . _test . assume_equal ( self . _knowledge_base_directory . _current_time_reply , 'my time' )
    def test_create_knowledge_base ( self ) :
        self . _mediator . create_knowledge_base ( 'my base' )
        self . _test . assume_equal ( self . _knowledge_base_directory . _create_knowledge_base , [ [ 'my base' ] ] )
    def test_rename_knowledge_base ( self ) :
        self . _mediator . rename_knowledge_base ( 'my base' , 'my new base' )
        self . _test . assume_equal ( self . _knowledge_base_directory . _rename_knowledge_base , [ [ 'my base' , 'my new base' ] ] )
    def test_copy_knowledge_base ( self ) :
        self . _mediator . copy_knowledge_base ( 'my base' , 'my new base' )
        self . _test . assume_equal ( self . _knowledge_base_directory . _copy_knowledge_base , [ [ 'my base' , 'my new base' ] ] )
    def test_list_knowledge_bases_request ( self ) :
        self . _mediator . list_knowledge_bases_request ( )
        self . _test . assume_true ( self . _knowledge_base_directory . _list_knowledge_bases_request )
    def test_knowledge_base_creation_time_request ( self ) :
        self . _mediator . knowledge_base_creation_time_request ( 'my base' )
        self . _test . assume_equal ( self . _knowledge_base_directory . _knowledge_base_creation_time_request , 'my base' )
    def test_knowledge_base_modification_time_request ( self ) :
        self . _mediator . knowledge_base_modification_time_request ( 'my base' )
        self . _test . assume_equal ( self . _knowledge_base_directory . _knowledge_base_modification_time_request , 'my base' )
    def test_knowledge_base_size_request ( self ) :
        self . _mediator . knowledge_base_size_request ( 'my base' )
        self . _test . assume_equal ( self . _knowledge_base_directory . _knowledge_base_size_request , 'my base' )
